﻿function showDialog(url, obj, width, height) {
	window.showModalDialog(url, obj, "dialogWidth=" + width + "px;dialogHeight=" + height + "px,scroll=off,resizable=no");

}



function openDialog(url, obj, width, height) {
	window.open(url, obj, 'height=' + height + ', width=' + width + ', top=0, left=0, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, status=no')
}

// 验证手机号
function VMobile(m) {
	var patrn = /((^0{0,1}13[0-9]{9}$)|(^0{0,1}15[0-9]{9}$)|(^0{0,1}18[0-9]{9}$))/;
	flag = patrn.test(m);
	return flag;
}


// 验证email
function VEmail(e) {
	var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	flag = reg.test(e);
	return flag;
}

// 验证用户名6-200
function VName(n) {
	var a = "@";
	if (n.indexOf(a) == -1) {
		var reg = /^[A-Za-z0-9]{6,200}$/;
		return reg.test(n);
	}
	else {
		if (VEmail(n) == true) {
			return true;
		}
	}
}

// 验证用户名6-20
function CheckName(n) {
    var a = "@";
    if (n.indexOf(a) == -1) {
        var reg = /^[A-Za-z0-9]{6,20}$/;
        return reg.test(n);
    }
    else {
        if (VEmail(n) == true) {
            return true;
        }
    }
}

// 验证操作员名称 不用了 中文不允许了
function VOperatorName(s) {
	// var reg = /^[\u4e00-\u9fa5]+$/;
	var a = "@";
	var reg = /^[A-Za-z0-9\u4e00-\u9fa5]+$/gi;
	if (s.indexOf(a) == -1) {
		if (!reg.test(s)) {
			return false;
		}
	}
	else {
		if (VEmail(s) == true) {
			return true;
		}
	}
	return true;
}

// 验证中文字符
function VChinese(s) {
	var reg = /^[\u4e00-\u9fa5]+$/;
	if (!reg.test(s)) {
		return false;
	}
	return true;
}




// 验证密码
function UserPwd(value, confirmvalue) {
	var comoanyUserPwd = value;
	if (comoanyUserPwd == null || comoanyUserPwd == ""  ) {
		return "密码不能为空";
	}
	else if (comoanyUserPwd.length == 0) {
		return "密码不能为空";
	}
	else if (comoanyUserPwd.length < 6) {
		return "密码不能少于六位";
	}
	else if (comoanyUserPwd.length > 20) {
		return "密码不能大于二十位";
	}
	else if (value != confirmvalue) {
	return "输入密码与确认密码不一致";
	}
	else {
		return "";
	}
}


// 验证电话
function VPhone(p) {
	var my = /((^[0-9]{3,4}\-[0-9]{7,8}$)|(^[0-9]{7,8}$)|(^[0-9]{3,4}-[0-9]{7,8}\/[0-9]{3,4})|([0-9]{3,4}\-[0-9]{7,8}\-[0-9]{3,4})|([0-9]{7,8}\/[0-9]{3,4})|([0-9]{7,8}-[0-9]{3,4}))$/;
	if (my.test(p)) {
		return true
	}
	else {
		return false
	}
}

// 判断邮编
function isPostCode(s) {
	var patrn = /(^[0-9]{5,10}$)/;
	if (!patrn.test(s)) {
		return false
	}
	else {
		return true
	}
}


// 验证时间
function IsNotFirst(startDate, endDate) {

	var pattern = /^(19|20)\d{2}-(0?\d|1[012])-(0?\d|[12]\d|3[01])$/;

	if (!pattern.test(startDate)) {
		alert("开始日期请输入yyyy-MM-dd此格式的时间!");
		return false;
	}


	if (!(pattern.test(endDate))) {
		alert("结束日期请输入yyyy-MM-dd此格式的时间!");
		return false;
	}

	startDate = startDate.replace(/-/g, "/");
	endDate = endDate.replace(/-/g, "/");

	if (startDate == "") {
		alert("开始时间不能为空");
		return false;
	}

	if (startDate == "") {
		alert("结束时间不能为空");
		return false;
	}

	if ((Date.parse(endDate) - Date.parse(startDate)) > 2592000000) {
		alert("查询时间跨度不能超过一个月");
		return false;
	}

	if ((Date.parse(endDate) - Date.parse(startDate)) < 0) {
		alert("开始时间不能大于结束时间");
		return false;
	}

	return true;

}


// 设置支付密码
function PwdIsnull(fpwd, epwd) {

	// var epwd = document.getElementById('<%= txtendPwd.ClientID %>').value;
	if (fpwd != "" && fpwd != null) {
		document.getElementById("span_firstPwd").innerHTML = "";
	}
	else {
		document.getElementById("span_firstPwd").innerHTML = "请输入支付密码!";
		return false;
	}
	if (fpwd.length < 6) {
		document.getElementById("span_firstPwd").innerHTML = "支付密码长度不能小于6位数!";
		return false;
	}


	if (epwd != '' && epwd != null) {
		document.getElementById("span_endPwd").innerHTML = "";
	}
	else {
		document.getElementById("span_endPwd").innerHTML = "请输入确认支付密码!";
		return false;
	}
	if (epwd.length < 6) {
		document.getElementById("span_endPwd").innerHTML = "支付密码长度不能小于6位数!";
		return false;
	}
	if (fpwd != epwd) {
		document.getElementById("span_endPwd").innerHTML = "支付密码与确认支付密码不一致,请重新输入!";
		return false;
	}
	else {
		document.getElementById("span_endPwd").innerHTML = "";
	}
}


// 设置登录密码的验证
function LoginPwdIsnull(oldpwd, fpwd, epwd) {

	if (oldpwd != '' && oldpwd != null) {
		document.getElementById("span1").innerHTML = "";
	}
	else {
		document.getElementById("span1").innerHTML = "请输入旧密码!";
	}
	if (fpwd != '' && fpwd != null) {
		document.getElementById("span_firstPwd").innerHTML = "";
	}
	else {
		document.getElementById("span_firstPwd").innerHTML = "请输入新密码!";
		return false;
	}
	if (fpwd.length < 6) {
		document.getElementById("span_firstPwd").innerHTML = "密码不能小于6位数,请重新输入!";
		return false;
	}
	if (epwd != '' && epwd != null) {
		document.getElementById("span_endPwd").innerHTML = "";
	}
	else {
		document.getElementById("span_endPwd").innerHTML = "请输入确认密码!";
		return false;
	}
	if (fpwd != epwd) {
		document.getElementById("span_endPwd").innerHTML = "新密码与确认密码不一致,请重新输入!";
		return false;
	}
	else {
		document.getElementById("span_endPwd").innerHTML = "";
	}

}



// 设置绑定支付宝密码
function AliPayPwdIsnull(fpwd, epwd) {

    // var epwd = document.getElementById('<%= txtendPwd.ClientID %>').value;
    if (fpwd != "" && fpwd != null) {
        document.getElementById("span_firstPwd").innerHTML = "";
    }
    else {
        document.getElementById("span_firstPwd").innerHTML = "请输入绑定支付宝密码!";
        return false;
    }
    if (fpwd.length < 6) {
        document.getElementById("span_firstPwd").innerHTML = "绑定支付宝密码长度不能小于6位数!";
        return false;
    }


    if (epwd != '' && epwd != null) {
        document.getElementById("span_endPwd").innerHTML = "";
    }
    else {
        document.getElementById("span_endPwd").innerHTML = "请输入确认绑定支付宝密码!";
        return false;
    }
    if (epwd.length < 6) {
        document.getElementById("span_endPwd").innerHTML = "绑定支付宝密码长度不能小于6位数!";
        return false;
    }
    if (fpwd != epwd) {
        document.getElementById("span_endPwd").innerHTML = "绑定支付宝密码与确认密码不一致,请重新输入!";
        return false;
    }
    else {
        document.getElementById("span_endPwd").innerHTML = "";
    }
}

// 设置提现密码
function TixianPwdPwdIsnull(fpwd, epwd) {

    // var epwd = document.getElementById('<%= txtendPwd.ClientID %>').value;
    if (fpwd != "" && fpwd != null) {
        document.getElementById("span_firstPwd").innerHTML = "";
    }
    else {
        document.getElementById("span_firstPwd").innerHTML = "请输入提现密码!";
        return false;
    }
    if (fpwd.length < 6) {
        document.getElementById("span_firstPwd").innerHTML = "提现密码长度不能小于6位数!";
        return false;
    }


    if (epwd != '' && epwd != null) {
        document.getElementById("span_endPwd").innerHTML = "";
    }
    else {
        document.getElementById("span_endPwd").innerHTML = "请输入确认提现密码!";
        return false;
    }
    if (epwd.length < 6) {
        document.getElementById("span_endPwd").innerHTML = "提现密码长度不能小于6位数!";
        return false;
    }
    if (fpwd != epwd) {
        document.getElementById("span_endPwd").innerHTML = "提现密码与确认密码不一致,请重新输入!";
        return false;
    }
    else {
        document.getElementById("span_endPwd").innerHTML = "";
    }
}

// 判断订单号(只能为数字)
function Checkorderid(obj) {
    var temp = /^([0-9]{0,})$/;
    if (temp.exec(obj)) {
        return true;
    }
    return false;
}
function isIdCardNew(num) {
    var IdeInfor = "";
    var len = num.length, re;
    var a;
    var date;
    if (len != 15 && len != 18) {
        return false;
    }
    else if (len == 15) {
        re = new RegExp(/^(\d{6})()?(\d{2})(\d{2})(\d{2})(\d{3})$/);
        regExp = num.match(re);
        if (isNaN(num)) {
            return false;
        }
        else if (!validateDate(num)) {
            return false;
        }
        else
            return true;
    }
    else if (len == 18) {
        re = new RegExp(/^(\d{6})()?(\d{4})(\d{2})(\d{2})(\d{3})(\d)$/);

        if ((len == 18 && isNaN(num.substring(0, 17))) || (len == 18 && isNaN(num.substring(17, 18)) && num.substring(17, 18) != "X" && num.substring(17, 18) != "x")) {
            return false;
        }
        else if (!validateDate(num)) {
            return false;
        }
        else
            return true;
    }
    else
        return true;
};
function validateDate(num) {

    if (num.length == 15) {
        if (parseInt(num.substring(8, 10), 10) > 12
			|| parseInt(num.substring(10, 12), 10) > 31
			 )
            return false;
        else
            return true;
    }

    else if (num.length == 18) {
        if (parseInt(num.substring(6, 10), 10) > 2500
			|| parseInt(num.substring(6, 10), 10) < 1900
			|| parseInt(num.substring(10, 12), 10) > 12
			|| parseInt(num.substring(12, 14), 10) > 31
			 )
            return false;
        else
            return true;
    }
};

function ajaxLoading(){ 
    $("<div class=\"datagrid-mask\"></div>").css({display:"block",width:"100%",height:$(window).height()}).appendTo("body"); 
    $("<div class=\"datagrid-mask-msg\" style=\"color:black;\"></div>").html("正在处理，请稍候。。。").appendTo("body").css({display:"block",left:($(document.body).outerWidth(true) - 190) / 2,top:($(window).height() - 45) / 2}); 
 } 
 function ajaxLoadEnd(){ 
     $(".datagrid-mask").remove(); 
     $(".datagrid-mask-msg").remove();             
} 
